import 'package:flutter/cupertino.dart';
import 'package:flutter_shader/main.dart';

/// Created by changlei on 2024/2/22.
///
/// 首页
class HomePage extends StatefulWidget {
  /// 首页
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: const CupertinoNavigationBar(
        middle: Text('首页'),
      ),
      child: Builder(
        builder: (context) {
          return SingleChildScrollView(
            padding: const EdgeInsets.all(16) + MediaQuery.viewPaddingOf(context),
            child: Wrap(
              spacing: 16,
              runSpacing: 16,
              children: R.values.where((element) => element != R.root).map((e) {
                return CupertinoButton.filled(
                  minSize: 0,
                  padding: const EdgeInsets.all(8),
                  borderRadius: BorderRadius.circular(5),
                  child: Text(e.name),
                  onPressed: () {
                    Navigator.pushNamed(context, e.routeName);
                  },
                );
              }).toList(),
            ),
          );
        },
      ),
    );
  }
}
